{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set menu = 'admin_setting_consult_setting' %}

{% set script_controller = 'setting/consult-setting' %}

{% block main %}

{{ web_macro.flash_messages() }}

<form class="form-horizontal" method="post" id="consult-setting-form" novalidate>
  <div class="row form-group">
    <div class="col-md-3 control-label">
      <label >{{'客服功能'|trans}}</label>
    </div>
    <div class="controls col-md-8 radios">
      {{ radios('enabled', {1:'开启'|trans, 0:'关闭'|trans}, consult.enabled) }}
    </div>
  </div>
  <div class="row form-group">
    <div class="col-md-3 control-label">
      <label >{{'浮动条颜色'|trans}}</label>
    </div>
    <div class="controls col-md-8 radios">
      {{ 
        radios('color', 
        {'default':'<span class="btn btn-lg" style="background:#37b97d"></span>', 
         'warning':'<span class="btn btn-lg" style="background:#e67e22"></span>',
          'danger':'<span class="btn btn-lg" style="background:#e74c3c"></span>'},
        consult.color) 
      }}
    </div>
  </div>
  <div data-role="template" style="display:none">
    <div class="row form-group has-feedback">
      <div class="controls col-md-2 col-md-offset-2">
        <input type="text" name="" class="form-control" value="" placeholder="">
      </div>
      <div class="controls col-md-2">
        <input type="text" name="" class="form-control" value="" placeholder="">
      </div>
      <div class="controls col-md-4">
        <input type="text" name="" class="form-control" value="" placeholder="">
        <button class="close delete-btn form-control-feedback" data-role="item-delete" type="button" title="{{'删除'|trans}}">×</button></input>
      </div>
    </div>
  </div>

  <div data-role="phone-template" style="display:none">
    <div class="row form-group has-feedback">
      <div class="controls col-md-4 col-md-offset-2">
        <input type="text" name="" class="form-control" value="" placeholder="">
      </div>
      <div class="controls col-md-4">
        <input type="text" name="" class="form-control" value="" placeholder="">
        <button class="close delete-btn form-control-feedback" data-role="phone-item-delete" type="button" title="{{'删除'|trans}}">×</button></input>
      </div>
    </div>
  </div>

  <div data-role="qqGroupTemplate" style="display:none">
    <div class="row form-group has-feedback">
      <div class="controls col-md-2 col-md-offset-2">
        <input type="text" name="" class="form-control" value="" placeholder="">
      </div>
      <div class="controls col-md-2">
        <input type="text" name="" class="form-control" value="" placeholder="">
      </div>
      <div class="controls col-md-4">
        <input type="text" name="" class="form-control" value="" placeholder="">
        <button class="close delete-btn form-control-feedback" data-role="item-delete" type="button" title="{{'删除'|trans}}">×</button></input>
      </div>
    </div>
  </div>

  <fieldset>
    <legend>QQ{{'客服设置'|trans}}
      <span class="glyphicon glyphicon-question-sign text-muted pull-right mll mts" id="qq-property-tips" data-toggle="tooltip" data-placement="bottom" href="javascript:" title="" data-original-title=""></span>
      <div id="qq-property-tips-html" style="display:none;">
        <div style="width:250px;">
          <span style="color:blue;">{{'如何获取在线咨询链接？'|trans}}</span><br>
          1，{{'登录'|trans}} <a target="_blank" href="https://id.b.qq.com/login/index">https://id.b.qq.com/login/index</a>。 <br>
          2，{{'登录后，找到【营销QQ】-【在线代码生成】，选择【在论坛/微博发布在线咨询链接】。（包含“%http%://”）'|trans({'%http%':app.request.getScheme()})}}<br>
        </div>
      </div>
    </legend>
    <div id="consult-qq">
      {% for qq in consult.qq %}
      <div class="row form-group has-feedback">
        <div class="controls col-md-2 col-md-offset-2">
          <input type="text" name="qq[{{loop.index0}}][name]" class="form-control" value="{{qq.name}}" placeholder="{{'QQ客服名称'|trans}}">
        </div>
        <div class="controls col-md-2">
          <input type="text" name="qq[{{loop.index0}}][number]" class="form-control" value="{{qq.number}}" placeholder="{{'QQ号'|trans}}">
        </div>
        <div class="controls col-md-4">
          <input type="text" name="qq[{{loop.index0}}][url]" class="form-control" value="{{qq.url|default('')}}" placeholder="{{'若使用营销QQ，请填入在线咨询链接'|trans}}">
          {% if loop.index0 > 0 %}
          <button class="close delete-btn form-control-feedback" data-role="item-delete" type="button" title="{{'删除'|trans}}">×</button>
          {% endif %}
        </div>
      </div>
      {% endfor %}
    </div>
    <div class="row form-group">
      <div class="controls col-md-4 col-md-offset-2">
        <span  class="btn-link" data-role="item-add" data-parentId='consult-qq' data-length='{{consult.qq | length}}'>{{'新增'|trans}}</span>
      </div>
    </div>
  </fieldset>


  <fieldset>
    <legend>{{'QQ群设置'|trans}}
      <span class="glyphicon glyphicon-question-sign text-muted pull-right mll mts" id="qq-group-property-tips" data-toggle="tooltip" data-placement="bottom" href="javascript:" title="" data-original-title=""></span>
      <div id="qq-group-property-tips-html" style="display:none;">
        <div style="width:250px;">
          <span style="color:blue;">{{'如何获取在线咨询链接？'|trans}}</span><br>
          {{'访问'|trans}}<a target="_blank" href="http://qun.qq.com/join.html">http://qun.qq.com/join.html</a>{{'获取QQ群直接加入网页代码。'|trans}}
        </div>
      </div>
    </legend>
    <div id="consult-qqgroup">
      {% for qqgroup in consult.qqgroup %}
      <div class="row form-group has-feedback">
        <div class="controls col-md-2 col-md-offset-2">
          <input type="text" name="qqgroup[{{loop.index0}}][name]" class="form-control" value="{{qqgroup.name }}" placeholder="{{'QQ群名称'|trans}}">
        </div>
        <div class="controls col-md-2">
          <input type="text" name="qqgroup[{{loop.index0}}][number]" class="form-control" value="{{qqgroup.number}}" placeholder="{{'QQ群号'|trans}}">
        </div>
        <div class="controls col-md-4">
          <input type="text" name="qqgroup[{{loop.index0}}][url]" class="form-control" value="{{qqgroup.url|default('')}}" placeholder="{{'QQ群直接加入网页代码(选填)'|trans}}">
          {% if loop.index0 > 0 %}
          <button class="close delete-btn form-control-feedback" data-role="item-delete" type="button" title="{{'删除'|trans}}">×</button>
          {% endif %}
        </div>
      </div>
      {% endfor %}
    </div>
    <div class="row form-group">
      <div class="controls col-md-4 col-md-offset-2">
        <span class="btn-link" data-parentId='consult-qqgroup' data-length='{{consult.qqgroup | length}}'>{{'新增'|trans}}</span>
      </div>
    </div>
  </fieldset>

  <fieldset>
    <legend>{{'联系电话设置'|trans}}</legend>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="worktime">{{'工作时间'|trans}}</label>
      </div>
      <div class="controls col-md-8">
        <input type="text" id="worktime" name="worktime" class="form-control" value="{{consult.worktime}}">
      </div>
    </div>
    

    <div id="consult-phone">
      {% for phone in consult.phone %}
      <div class="row form-group has-feedback">
        <div class="controls col-md-4 col-md-offset-2">
          <input type="text" name="phone[{{loop.index0}}][name]" class="form-control" value="{{phone.name}}" placeholder="{{'联系人'|trans}}">
        </div>
        <div class="controls col-md-4">
          <input type="text" name="phone[{{loop.index0}}][number]" class="form-control" value="{{phone.number}}" placeholder="{{'联系电话'|trans}}">
          {% if loop.index0 > 0 %}
          <button class="close delete-btn form-control-feedback" data-role="phone-item-delete" type="button" title="{{'删除'|trans}}">×</button>
          {% endif %}
        </div>
      </div>
      {% endfor %}
    </div>
    <div class="row form-group">
      <div class="controls col-md-4 col-md-offset-2">
        <span class="btn-link"  data-role="phone-item-add" data-parentId='consult-phone' data-length='{{consult.phone | length}}'>{{'新增'|trans}}</span>
      </div>
    </div>
  </fieldset>
  
  <fieldset>
    <legend>{{'其他设置'|trans}}</legend>
    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label>{{'微信二维码'|trans}}</label>
      </div>
      <div class="col-md-8 controls">
        <div id="consult-container">{% if consult.webchatURI %}<img src="{{ asset(consult.webchatURI) }}">{% endif %}</div>
        <a href="javascript:;" class="btn btn-default btn-sm" id="consult-upload" data-upload-token="{{ upload_token('system', 'image') }}"type="button" data-goto-url="{{ path('admin_setting_consult_upload') }}">{{'上传'|trans}}</a>
        <button class="btn btn-default btn-sm" id="consult-webchat-del" type="button" data-url="{{ path('admin_setting_consult_webchat_delete') }}" {% if not consult.webchatURI %}style="display:none;"{% endif %}>{{'删除'|trans}}</button>        
        <p class="help-block">{{'请上传png, gif, jpg格式的图片文件。'|trans}}</p>
        <input type="hidden" name="webchatURI" value="{{ consult.webchatURI }}">
      </div>
    </div>
    

    <div class="row form-group">
      <div class="col-md-2 control-label">
        <label for="email">{{'工作邮箱'|trans}}</label>
      </div>
      <div class="controls col-md-8">
        <input type="text" id="email" name="email" class="form-control" value="{{consult.email}}">
      </div>
    </div>
  </fieldset>

  

  <div class="row form-group">
    <div class="col-md-3 control-label"></div>
    <div class="controls col-md-8">
      <button type="submit" class="btn btn-primary">{{'提交'|trans}}</button>
    </div>
  </div>

  <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
</form>

{% endblock %}